className = get_class();// Set current class $this->zColumnList = array("dataId", "createDate","OrgID","Name","MesurementUnit","Discount","MRP","Status","Direction"); $this->zColumnType = array("VARCHAR(8)", "VARCHAR(32)","VARCHAR(8)","VARCHAR(64)","VARCHAR(8)","DECIMAL","DECIMAL","VARCHAR(4)","VARCHAR(4)"); if($OrgID!="" && $Name!=""){ $this->OrgID=$OrgID; $this->Name=$Name; $this->MesurementUnit=$Unit; $this->Discount=$Discount; $this->MRP=$MRP; $this->Status=$Status; $this->Direction=$Direction; $this->_save(); } } public function _update($id="",$Name="",$Unit="",$Discount=0,$MRP=0,$Status="",$Direction=""){ if($id!=""){ $this->_openById($id); if($Name!="") $this->Name=$Name; if($Unit!="") $this->MesurementUnit=$Unit; if($Direction=!"") $this->Direction=$Direction; $this->Discount=$Discount; $this->MRP=$MRP; if($Status!="") $this->Status=$Status; return $this->_save(); } } } /* class premises extends cover{ public $OrgID; public $KMC_ID; public $AddressRef; public $Supervisor; public $Status; public function __construct($OrgID="",$KMC_ID="",$AddRef="",$Supervisor="",$Status="Active"){ parent::__construct(classN: 'premises',idPre:"P-"); $this->className = get_class();// Set current class $this->zColumnList = array("dataId", "createDate","OrgID","KMC_ID","AddressRef","Supervisor","Status"); $this->zColumnType = array("VARCHAR(8)", "VARCHAR(32)","VARCHAR(8)","VARCHAR(8)","VARCHAR(8)","VARCHAR(8)","VARCHAR(4)"); if($OrgID!="" && $KMC_ID!=""){ $this->OrgID=$OrgID; $this->KMC_ID=$KMC_ID; $this->AddressRef=$AddRef; $this->Supervisor=$Supervisor; $this->Status=$Status; $this->_save(); } } public function _update($id="",$KMC_ID="",$AddRef="",$Supervisor="",$Status=""){ if($id!=""){ $this->_openById($id); if($KMC_ID!="") $this->KMC_ID=$KMC_ID; if($AddRef!="") $this->AddressRef=$AddRef; if($Supervisor!="") $this->Supervisor=$Supervisor; if($Status!="") $this->Status=$Status; $this->_save(); } } } */ class transaction extends data{ public $OrgID; public $TeamID; public $ItemID; public $RelatedUser; public $AmountIn; public $AmountOut; public $Comments; public function __construct($OrgID="",$cBy="System",$TeamID="",$ItemID="",$RelatedUser="",$AmountIn=0,$AmountOut=0,$Comments=""){ parent::__construct(classN: 'transaction',idPre:"T-",cBy:$cBy); $this->className = get_class();// Set current class $this->zColumnList = array("dataId", "createDate","createdBy","OrgID","TeamID","ItemID","RelatedUser","AmountIn","AmountOut","Comments"); $this->zColumnType = array("VARCHAR(8)", "VARCHAR(32)","VARCHAR(8)","VARCHAR(8)","VARCHAR(8)","VARCHAR(8)","VARCHAR(8)","DECIMAL","DECIMAL","VARCHAR(64)"); //For search and reporting only $this->zReportCols = array("dataId", "createDate","createdBy","TeamID","ItemID","RelatedUser","AmountIn","AmountOut","Comments");//zBlob should not be here $this->zReportColsHeader = array("ID","Date","Created By","Team","Item","Related User","Amount In","Amount Out","Comments");//zBlob should not be here if($OrgID!="" && ($AmountIn>0 || $AmountOut>0)){ $this->OrgID=$OrgID; $this->TeamID=$TeamID; $this->ItemID=$ItemID; $this->RelatedUser=$RelatedUser; $this->AmountIn=$AmountIn; $this->AmountOut=$AmountOut; $this->Comments=$Comments; $this->_save(); } } public function _update($id="",$TeamID="",$ItemID="",$RelatedUser="",$AmountIn=0,$AmountOut=0,$Comments=""){ if($id!="" && ($AmountIn>0 || $AmountOut>0)){ $this->_openById($id); if($TeamID!="") $this->TeamID=$TeamID; if($ItemID!="" ) $this->ItemID=$ItemID; if($RelatedUser!="") $this->RelatedUser=$RelatedUser; if($AmountIn>0) $this->AmountIn=$AmountIn; if($AmountOut>0) $this->AmountOut=$AmountOut; if($Comments!="") $this->Comments=$Comments; $this->_save(); } } } function hasRole($userID="",$requiredRole="USR") { $usr = new user(); $data = $usr->_getUserContext(); if($userID=="" || $data->workId==$userID){ return $data->role===$requiredRole; }else{ $tmpObj = $usr->_browse(select:"role",where:"workId='$userID'",isExecute:true); if($tmpObj->status==true){ return $tmpObj->results[0]->role===$requiredRole; } return false; } return false; } function isAdmin($userID=""){ return hasRole($userID,"ADM"); } function isUser($userID=""){ return hasRole($userID,"USR"); } function isManager($userID=""){ return hasRole($userID,"MGR"); } function addTransactionFromAPI($contact="",$item="I-8",$type="owner",$amount=0,$comments=""){ $usr = new user(); $uList = $usr->_list(select:"workId,orgID,userGroup",where:"contact='$contact'"); if($uList->resultsCount==1){ if($type=="O"){ $t = new transaction(OrgID:$uList->results[0]->orgID,cBy:$uList->results[0]->workId,TeamID:$uList->results[0]->userGroup,ItemID:$item,AmountIn:$amount,Comments:$comments,RelatedUser:$uList->results[0]->workId); }elseif($type=="T"){ $t = new transaction(OrgID:$uList->results[0]->orgID,cBy:$uList->results[0]->workId,TeamID:$uList->results[0]->userGroup,ItemID:$item,AmountOut:$amount,Comments:$comments,RelatedUser:$uList->results[0]->workId); }else{} } } /* //Run first tiome to generate tables $o = new organization(); $o->_createTable(true); $org = new organization(oNam:"PocketNote"); $orgId = $org->dataId; echo "Organization Created ID#$orgId
"; $t = new team(); $t->_createTable(true); $tm = new team(tNam:"Default",oId:$orgId); $tmId= $tm->dataId; echo "Team Created ID#$tmId
"; $ad = new address(); $ad->_createTable(true); $i = new item(); $i->_createTable(true); $tr = new transaction(); $tr->_createTable(true); echo "Table Created for Address & Transactions
"; $u = new user(); $u->_createTable(true); $flg= $u->_addNewUser(name:"Rajat",email:"rajat70@gmail.com",contact:"9748448117",teamId:$tmId,orgID:$orgId); echo "User #$u->workId created
"; */ ?>